﻿namespace ParkingLot4
{
    public class ParkingLotManagerOfIndexFirst: ParkingLotManagerBase
    {
        /// <summary>
        /// 有一个停⻋小弟管理着两个停⻋场，他的停⻋策略是第一个停⻋场停满之后，再停到第二个停⻋场
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public override ParkingLot ChooseParkLot()
        {
            if (parkingLots == null || parkingLots.Count() != 2)
                throw new Exception("停车场初始化错误");
            if (!parkingLots.First().IsParkingLotFull())
                return parkingLots.First();
            if (!parkingLots.ToList()[1].IsParkingLotFull())
                return parkingLots.ToList()[1];
            throw new InvalidOperationException("没有可用停车场");
        }
    }
}
